package com.weilaiwd.common.handler;

import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import com.jfinal.handler.Handler;
import com.jfinal.kit.Prop;
import com.jfinal.kit.PropKit;

public class ConfigHandler extends Handler {
	 
	@Override
	public void handle(String target, HttpServletRequest request,
			HttpServletResponse response, boolean[] isHandled) {
		Prop prop = PropKit.use("config.properties");
		Properties p = prop.getProperties();
		Set<Object> set = p.keySet();
		Iterator<Object> iter = set.iterator();
		while(iter.hasNext()) {
			Object key = iter.next();
			request.setAttribute(key.toString(), prop.get(key.toString()));
		}
		nextHandler.handle(target, request, response, isHandled);
	}

}
